﻿using AgencyManagerSystem.AsmType;
using AgencyManagerSystem.Common;
using AgencyManagerSystem.DataFetcher;
using AgencyManagerSystem.DataUpdater;
using AgencyManagerSystem.Model;
using System.Collections.Generic;

namespace AgencyManagerSystem.Core
{
    public class RetailMemberManager : DocManager<RetailMemberModel>
    {
        RetailMemberUpdater updater;
        protected override BaseUpdater<RetailMemberModel> InjectionUpdater()
        {
            RetailMemberUpdaterCreator retailUpdaterCreator = new RetailMemberUpdaterCreator();
            updater = retailUpdaterCreator.CreateRetailUpdaterInstance();
            return updater;
        }
        public virtual AsmArray<RetailMemberModel> UpdateList(int retail, IEnumerable<RetailMemberModel> models)
        {
            string message;
            bool result = updater.UpdateForRetail(retail,models, out message);
            if (!result)
            {
                DBHelper.Commit( false);
                return new AsmArray<RetailMemberModel>() { Message = message, Result = AmsCode.InnError };
            }

            else
            {
                return new AsmArray<RetailMemberModel>() { Message = "操作成功", Result = AmsCode.Succ, Data = models };
            }
        }
    }
}